var express = require('express')
var router = express.Router()
var cartControllers = require('../controllers/cart')

/* GET home page. */
// 获取购物车数据
// username
router.get('/list', function (req, res, next) {
	console.log('qq')
	cartControllers.getcart(req.query, (result) => {
		res.json(result)
	})
})
// 更新购物车数据
// username，goods_id  qty
router.post('/update', (req, res) => {
	cartControllers.updatecart(req.body, (result) => {
		res.json(result)
	})
})
// 删除购物车数据
// username，goods_id
router.post('/del', (req, res) => {
	cartControllers.delcart(req.body, (result) => {
		res.json(result)
	})
})
// 添加购物车
// 购物车所有信息
router.post('/add', (req, res) => {
	cartControllers.addcart(req.body, (result) => {
		res.json(result)
	})
})

module.exports = router
